define(function (require, exports, module) {

  require("mixins/global.mixins.js");
  var mCard = require('andrew/card/index.js');
  var toastr = require("third/toastr/index.js");

  var api = require('service/api.js');

  var pageVue = new Vue({
    data: {
      tableList: [],
      searchForm: {
        jobType: null,
        runDate:''
      },
      jobTypeEnum: [],
      OneCategoryList: [],
      TwoCategoryList: [],
      selectedOptions: [],
      formCollapse: false,
      pageSizes: [5, 10, 20, 30],
      currentPage: 1,
      pageSize: 5,
      totalCount: 0
    },
    mounted: function () {
      this.getDataList();
      console.log(this.Enum);
    },
    methods: {
      handleChange: function (value) {
        console.log(value);
      },
      clearSearch: function () {
        this.searchForm.jobType = null;
        this.searchForm.runDate = '';
      },
      clearThenSearch: function () {
        this.clearSearch();
        this.getDataList();
      },
      toggleSearhBodyCollapse: function () {
        this.formCollapse = !this.formCollapse;
      },
      onSubmit: function () {
        this.getDataList();
      },
      getDataList: function () {

        var curPageVue = this;

        var query = {};

        if (curPageVue.searchForm.jobType != null && curPageVue.searchForm.jobType >= 0) {
          query['jobType'] = curPageVue.searchForm.jobType;
        }
        if (curPageVue.searchForm.runDate != null && curPageVue.searchForm.runDate != '') {
            query['runDate'] = curPageVue.searchForm.runDate;
        }
        query['pageSize'] = curPageVue.pageSize;
        query['pageNo'] = curPageVue.currentPage;

        api.getJobList({
          params: query,
          callBack: function (res) {
            curPageVue.tableList = res.list;
            curPageVue.totalCount = res.total;
          }
        })
      },
      handleSizeChange: function (val) {
        this.pageSize = val;
        this.currentPage = 1;
        this.getDataList();
      },
      handleCurrentChange: function (val) {
        this.currentPage = val;
        this.getDataList();
      },
      handleImportBookId: function () {
          var index = layer.open({
              type: 2,
              title: '导入书号',
              shade: [0],
              area: ['50%', '80%'],
              content: ['08_importBookId.html'], // iframe的url，no代表不显示滚动条
              end: function () { // 此处用于演示

              }
          });
      },
      handleStartJob: function () {
          api.handleStartJob({
              callBack: function (res) {
                toastr.success(res.msg);
              }
          })
      },

    }

  }).$mount('#app')
})
